package com.xjh.basestudy.javabase.threadjiu;

public class Copier {
    private String name;

    public Copier(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public synchronized void copyPages(int pages) {
        Thread employee = Thread.currentThread();//得到当前的“员工”的线程
        System.out.println(employee.getName() + "\t正在使用复印机\t" + name);
        long time = pages * 1000;
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            System.out.println("对不起程序出错，错误信息为：" + e.getMessage());
        }
        System.out.println(employee.getName() + "\t用完了打印机\t" + name);
    }

}
